package com.matrix.draft.dubbotest.ai.controller;

import com.matrix.draft.dubbotest.interfaces.BigDataService;
import com.matrix.draft.dubbotest.interfaces.FoodService;
import com.matrix.draft.dubbotest.pojo.dto.ChocolateDTO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;


@RestController
@RequestMapping("")
public class IndexController {

    @DubboReference
    BigDataService bigDataService;

    @DubboReference(loadbalance = "random")
    FoodService foodService;

    @RequestMapping("")
    Object index(@RequestParam(value = "n",defaultValue = "1",required = false) Integer n) {
        return bigDataService.getData(n);
    }

    @RequestMapping("/foods")
    Collection<ChocolateDTO> getFoods(){
        return foodService.getFoods();
    }

}
